package model;
/*
 * The Abstract User class.
 * 
 * @author Abdiel Cabrera
 */

/**
 * Abstract User class.
 * 
 * @author Abdiel Cabrera.
 * @date Winter 2014
 */
public abstract class User
{

	/** The name of this user. */
	protected String my_first_name = "";
	
	/** The name of this user. */
	protected String my_last_name = "";

	/** The userName of this user. */
	protected String my_userName;

	/** The password of this user. */
	protected String my_password;

	/** The phone of this user. */
	protected String my_phone;

	/** The enum of the user type */
	protected UserTypeEnum my_user_type = UserTypeEnum.UT_BLANK;
	
	/** The address of this user. */
	private Address my_address; 

	/** The email of this user. */
	protected String my_email;

	/** The access level of this user. */
	private int my_accessLevel;
	// my_accessLevel:
	// -1 = No access whatsoever
	// 1 = AuctionCentral Director
	// 2 = Auction Central Employee
	// 3 = Non-profit
	// 4 = Bidder

	/** 
	 * 
	 * @pre the_first_name != null
	 * @pre the_last_name != null
	 * @pre the_userName != null
	 * @pre the_password != null
	 * @pre the_phone != null
	 * @pre the_address != null
	 * @pre the_email != null
	 * @pre the_accessLevel = -1 || (the_accessLevel > 0 && the_accessLevel < 5)
	 * 
	 * @param the_first_name The first name
	 * @param the_last_name The last name
	 * @param the_userName The user name
	 * @param the_password The password
	 * @param the_phone The phone
	 * @param the_address The address
	 * @param the_email The e-mail
	 * @param the_accessLevel The acces level of this user
	 * Construct a User object. 
	 *
	 */
	public User(String the_first_name, String the_last_name, String the_userName, String the_password,
	String the_phone, Address the_address, String the_email, int the_accessLevel)
	{
		my_first_name = the_first_name;
		my_last_name = the_last_name;
		my_userName = the_userName;
		my_password = the_password;
		my_phone = the_phone;
		my_address = the_address;
		my_email = the_email;
		my_accessLevel = the_accessLevel; // 0 is an empty value, realistic access level ranges from 1 to 4
	}

	/**
	 * Returns the first name of the User.
	 * 
	 * @post my_first_name != null
	 * @return the my_first_name The first name.
	 */
	public String get_first_name() {
		return my_first_name;
	}

	/**
	 * Sets the first name of the User.
	 * 
	 * @pre the_name != null
	 * @param my_first_name the my_name to set
	 */
	public void set_first_name(String the_name) {
		this.my_first_name = the_name;
	}
	
	/**
	 * Returns the last name of the User.
	 * 
	 * @post my_last_name != null
	 * @return the my_last_name
	 */
	public String get_last_name() {
		return my_last_name;
	}

	/**
	 * Sets the last name of the User.
	 * 
	 * @pre the_last_name != null
	 * @param my_last_name the my_name to set
	 */
	public void set_last_name(String the_name) {
		this.my_last_name = the_name;
	}

	/**
	 * Return the userName of the User.
	 * 
	 * @post my_userName != null
	 * @return the my_userName
	 */
	public String getMy_userName() {
		return my_userName;
	}

	/**
	 * Sets the userName of the User
	 * 
	 * @pre the_userName != null
	 * @param my_userName the my_userName to set
	 */
	public void setMy_userName(String the_userName) {
		this.my_userName = the_userName;
	}

	/**
	 * Return the password of the User.
	 * 
	 * @post my_password != null
	 * @return the my_password
	 */
	public String getMy_password() {
		return my_password;
	}

	/**
	 * Sets the password of the User.
	 * 
	 * @pre my_password != null
	 * @param my_password the my_password to set
	 */
	public void setMy_password(String the_password) {
		this.my_password = the_password;
	}

	/**
	 * Returns the phone of the User.
	 * 
	 * @post my_phone != null
	 * @return the my_phone
	 */
	public String getMy_phone() {
		return my_phone;
	}

	/**
	 * Sets the phone of the User.
	 * 
	 * @pre my_phone != null
	 * @param my_phone the my_phone to set
	 */
	public void setMy_phone(String the_phone) {
		this.my_phone = the_phone;
	}

	/**
	 * Returns the address of the User
	 * 
	 * @post my_address != null
	 * @return the my_address
	 */
	public Address getMy_address() {
		return my_address;
	}

	/**
	 * Sets the address of the User
	 * 
	 * @pre the_address != null
	 * @param my_address the my_address to set
	 */
	public void setMy_address(Address the_address) {
		this.my_address = the_address;
	}

	/**
	 * Returns the email of the User.
	 * 
	 * 
	 * @post my_e-mail != null
	 * @return the my_email
	 */
	public String getMy_email() {
		return my_email;
	}

	/**
	 * Sets the email of the User.
	 * 
	 * @pre the_email != null
	 * @param my_email the my_email to set
	 */
	public void setMy_email(String the_email) {
		this.my_email = the_email;
	}

	/**
	 * Return the access level of this User.
	 * 
	 * @post the_accessLevel = -1 || (the_accessLevel > 0 && the_accessLevel < 5)
	 * @return the my_accessLevel
	 */
	public int getMy_accessLevel() {
		return my_accessLevel;
	}

	/**
	 * Sets the access level of this User.
	 * 
	 * @pre the_accessLevel = -1 || (the_accessLevel > 0 && the_accessLevel < 5)
	 * @param my_accessLevel the my_accessLevel to set
	 */
	public void setMy_accessLevel(int the_accessLevel) {
		this.my_accessLevel = the_accessLevel;
	}
	
	/**
	 * Checks for a valid User.
	 * @post returns if the requested user is allowed to login
	 * 
	 * @param the_userName The userName of the User.
	 * @param the_password The password of the User.
	 * @return TRUE if credentials accepted and FALSE otherwise.
	 */
	public boolean isValidUser(String the_userName, String the_password)
	{
		// the password was removed because is was in the requirements not to use security
		if (the_userName.equals(this.my_userName) && my_accessLevel >= 0) 
		{	
			return true;
		} 
		else return false;
	}

	/**
	 * @return the my_user_type
	 */
	public UserTypeEnum get_userType() {
		return my_user_type;
	}
	
	/**
	 * ToString lists all fields delimited by ~
	 */
	public String toString() {
		String result;
		result = my_first_name + "~" + my_last_name + "~" + my_userName + "~" + my_password
				 + "~" + my_phone + "~" + my_email;
		return result;
	}

}
